import esp32
import machine
import time
from machine import Pin

relay1 = Pin(8, Pin.OUT)    # 继电器1
relay2 = Pin(11, Pin.OUT)   # 继电器2
relay3 = Pin(6, Pin.OUT)    # 继电器3

def relay_ctrl(relay, state):
    if state == 0:
        relay.off()
    elif state == 1:
        relay.on()

if __name__ == '__main__':
    print('hello esp32c3')
    relay_ctrl(relay1, 1)
    relay_ctrl(relay2, 1)
    relay_ctrl(relay3, 1)
    time.sleep(1)
    relay_ctrl(relay1, 0)
    relay_ctrl(relay2, 0)
    relay_ctrl(relay3, 0)
